import { Observer } from "mobx-vue"
import { Component, Vue } from "vue-property-decorator";
import PubArea from 'src/views/components/pubArea/pubArea.vue';
import {  addGrid } from 'src/utils/axios'

@Observer
@Component({
  props: {
    clear: {
      type: Boolean,
      default: false
    }
  },
  components: {
    PubArea
  }
})
export default class GridAdd extends Vue {
    isShowModel: boolean = false;
    formItem:any={
      name: "",
      content: "",
    }
    departmentList:any=[]
    mounted() {
      let vm: any = this;
      vm.isShowModel = true;
      vm.getDepartment();
    }
    //关闭
  close() {
    let vm: any = this;
    let xwindow: any = window
    vm.isShowModel = false;
    if (!vm.clear) {
      xwindow.clearBodyStyle()
    }
    vm.$emit('close')
  }
  //确定
  async confirm() {
    let vm: any = this;
    let xwindow: any = window
    let areaParams=vm.$refs.area.formInline;
    let param={...vm.formItem, street_code: areaParams.street_code, community_code: areaParams.community_code}
    let out:any = await addGrid(param);
    if (!out.status) {
          vm.isShowModel = false;
          if (!vm.clear) {
              xwindow.clearBodyStyle()
          }
          vm.$emit('confirm')
    }else {
      vm.$Message.error(out.error.msg)
    }
  }
}